package com.learnyou.server.xingzuo.controller.common.impl;

import cn.hutool.core.date.DateUnit;
import com.learnyou.server.xingzuo.biz.common.SmsSendBiz;
import com.learnyou.server.xingzuo.biz.handle.annotation.IpFreqLimit;
import com.learnyou.server.xingzuo.common.constants.ApiCodeConstants;
import com.learnyou.server.xingzuo.controller.common.SmsSendResource;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author heweifeng
 * @Description:
 * @date 2022/12/3 15:29
 */
@RestController
public class SmsSendController implements SmsSendResource {

    @Resource
    private SmsSendBiz smsSendBiz;

    @IpFreqLimit(title = "注册短信验证码发送", code = ApiCodeConstants.VERIFY_CODE_SEND, timeUnit = DateUnit.HOUR, timeLimit = 24, maxReqCount = 5)
    @Override
    public Boolean sendVerifyCode(String phone) {
        return smsSendBiz.sendVerifyCode(phone);
    }

    @Override
    public Boolean checkVerifyCode(String phone, String code) {

        return smsSendBiz.checkVerifyCode(phone, code);
    }
}
